import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/home',
    component: () => import('@/views/Home'),
    children: [
      {
        path: '/home/hot',
        component: () => import('@/views/homes/Hot'),
        meta: {
          keepAlive: true // 缓存此页面
        }
      },
      {
        path: '/home/premie',
        component: () => import('@/views/homes/Premie')
      },
      {
        path: '/home',
        redirect: '/home/hot'
      }
    ]
  },
  {
    name: 'data',
    path: '/data/:id',
    component: () => import('@/views/homes/Data') // 懒加载
  },
  {
    path: '/cinema',
    component: () => import('@/views/Cinema')
  },
  {
    name: 'cinemasitem',
    path: '/cinemasitem/:id',
    component: () => import('@/views/cinemas/CinemasItem')
  },
  {
    path: '/city',
    component: () => import('@/views/cinemas/City')
  },
  {
    path: '/search',
    component: () => import('@/views/cinemas/Search')
  },
  {
    path: '/mine',
    component: () => import('@/views/Mine')
  },
  {
    path: '/login',
    component: () => import('@/views/Login')
  },
  {
    path: '*',
    redirect: '/home'
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
